package org.hybo.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import top.hmtools.ckfinder.configuration.BaseCommandConfig;
import top.hmtools.ckfinder.enums.ECommandHandler;

@Controller
public class MainController {

	@Autowired
	private BaseCommandConfig baseCommandConfig;
	
	@RequestMapping("/")
	@ResponseBody
	public String aaa(){
		return "current AbstractConfig class is :  "+baseCommandConfig;
	}
	
	@RequestMapping("/execute")
	@ResponseBody
	public String execute(@RequestParam(required=true,value="cmd")String cmd){
		try {
			ECommandHandler commandHandlerEnum = ECommandHandler.valueOf(cmd.toUpperCase());
			return commandHandlerEnum.getCommand().executeCommand()+"   >> "+JSON.toJSONString(commandHandlerEnum.getCommand().executeCommand());
		} catch (Exception e) {
			return "没有你的操作指令";
		}
	}
	
}
